/*
 * File:    Main.c
 * Project:	HobbyPilotFirmware (HPF)
 * Author:  Wouter
 *
 * Created on February 8, 2011, 9:17 PM
 */

#include "Header.h"

_FOSC(CSW_FSCM_OFF		// Disable clock source switching
    & FRC_PLL8);		// 10-25MHz external crystal, 4xPLL enabled
_FWDT(WDT_OFF);			// Turn the watchdog timer off
_FBORPOR(MCLR_DIS		// Enable the MCLR pin
    & PBOR_OFF			// No brown-out voltage detection
	& BORV27			// Brown-out voltage at 2.7V
	& PWRT_64);			// 64ms reset timer
_FGS(CODE_PROT_OFF);	// Don't code protect the registers

int main(void)
{
    __delay_ms(1000);       // Delay everything for 1 second


    initUART1();           // Initialize the UART module
	initADC();
    initTimer1();          // Initialize Timer1
	initTimer2();          // Initialize Timer2
	initTimer3();          // Initialize Timer3
    initTimer4();          // Initialize Timer4
	initOC();			   // Initialize the Output Compare module
    initIO();              // Initialize the IO ports
    initInterrupts();      // Initialize the interrupts

	Nop();	

    while(1)
    {
		if (T4CONbits.TON)
        	T4CONbits.TON = 0;
		else 
			Nop();
    }
    return 0;
}
